package org.java2me.mobileboxing;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

/**
 * Created by IntelliJ IDEA.
 * User: aterreno
 */
public class MobileBoxingCommandListener implements CommandListener {
    public static final Command START = new Command("Start", Command.SCREEN, 0);
    public final static Command PAUSE = new Command("Pause", Command.SCREEN, 1);
    public final static Command EXIT = new Command("Exit", Command.EXIT, 2);
    
    private final MobileBoxingMidlet midlet;

    public MobileBoxingCommandListener(MobileBoxingMidlet midlet) {
        this.midlet = midlet;
    }

    public void commandAction(Command command, Displayable displayable) {
        if (command == PAUSE) {
            midlet.pause();
        } else if (command == EXIT) {
            midlet.destroyApp(true);
            midlet.notifyDestroyed();
        } else if (command == START) {
            midlet.start();
        } 
    }
}
